from typing import List


class Solution:
    def countWays(self, nums: List[int]) -> int:
        n = len(nums)
        res = 0
        nums.sort()
        for k in range(0,n+1):
            if k >0 and nums[k-1] >= k:
                continue
            if k < n and nums[k] <= k:
                continue
            res += 1
        return res